
<script>
import UniIcon from 'uview-ui/components/u-icon/u-icon';

export default {
  props: {
    dataList: {
      type: Array,
      default: () => []
    }
  },

  methods: {
    itemClick(item) {
      this.$emit('itemClick', item);
    }
  },

  render(h) {
    const { itemClick } = this;
    const ListItem = this.dataList.map(item => {
      return h(
        'view',
        {
          class: 'c-list-item',
          on: {
            click: () => itemClick(item)
          }
        },
        [
          h('view', item.name),
          h(UniIcon, {
            props: {
              color: '#C0C4CC',
              name: 'arrow-right',
              size: 34
            }
          })
        ]
      );
    });

    return (
      <view class='c-list'>
        { ListItem }
      </view>
    );
  }
};
</script>

<style lang="scss" scoped>
.c-list {
  .c-list-item {
    background-color: #fff;
    color: #333;
    display: block;
    padding: 20px;
    position: relative;
    display: flex;
    justify-content: space-between;
    padding-right: 25px;
    &::after {
      content: '';
      display: block;
      position: absolute;
      left: 20px;
      right: 0px;
      height: 1px;
      bottom: 3px;
      background-color: #EDEDEE;
    }
  }
}
</style>
